
#ifndef __GLMM_DEVICE_H__
#define __GLMM_DEVICE_H__

#include "glmmdevicecapabilities.h"
#include "glmmiindexbuffer.h"
#include "glmmivertexbuffer.h"
#include "glmmivertexdefinition.h"
#include "glmmprimtype.h"
#include "glmmresult.h"
#include "glmmusage.h"

class glmmDevice {
private:
    glmmDeviceCapabilities caps;
    
    glmmIVertexBuffer*          vertexStreams [8];
    glmmIIndexBuffer*           indices;

    glmmIVertexDefinition*      definition;

public:
    glmmDevice();


    /**
     * Get the capabilities of the OpenGL device.
     *
     * @param[out]  caps The capabilities of the OpenGL device are written here.
     *
     * @return GLMM_OK if succeeded.
     */
    GLMMRESULT GetDeviceCapabilities(glmmDeviceCapabilities* caps);


    /**
     * Create a new VertexBuffer.
     * 
     * @param [in] size           The Memory given in bytes the VertexBuffer should use.
     * @param [in] usage          The way the VertexBuffer is used.
     * @param [out] out           Point on the VertexBuffer pointer;
     * 
     * @return GLMM_OK when the buffer was created  successfully.
     */
    GLMMRESULT CreateVertexBuffer(unsigned size, GLMMUSAGE usage, glmmIVertexBuffer** out);

    /**
     * Create a new IndexBuffer.
     * 
     * @param [in] size           The Memory given in bytes the IndexBuffer should use.
     * @param [in] type           The datatype of each element
     * @param [in] usage          The way the VertexBuffer is used.
     * @param [out] out           Point on the VertexBuffer pointer;
     * 
     * @return GLMM_OK when the buffer was created  successfully.
     */
    GLMMRESULT CreateIndexBuffer(unsigned size, GLMMDATATYPE type, GLMMUSAGE usage, glmmIIndexBuffer** out);
    
    /**
     * Create a VertexDefinition object based on the descriptions given in desc.
     * 
     * @param [in] desc
     * @param [out] out
     * @return GLMM_OK when all ok.
     */
    GLMMRESULT CreateVertexDefinition (const GLMMVERTEXDESCRIPTION* desc, glmmIVertexDefinition** out);
    
    /**
     * Sets the Datasource for the given Stream
     * 
     * @param [in] stream The stream index. 
     * @param [in] source The source to put into the stream.
     * @return GLMM_OK when ok.
     */
    GLMMRESULT SetStreamSource (unsigned stream, glmmIVertexBuffer* source);

    /**
     * Sets the description of the Vertices used within the Stream sources.
     * 
     * @param [in] desc The description how the stream sources should be interpreted.
     * @return GLMM_OK when ok
     */
    GLMMRESULT SetVertexDefinition (glmmIVertexDefinition* definition);

    /**
     * Sets the indices that should be used for drawing the data from the sources
     * 
     * @param [in] indices The indexbuffer containing the indices used for drawing.
     * @return GLMM_OK when ok.
     */
    GLMMRESULT SetIndices (glmmIIndexBuffer* indices);
    
    /**
     * Draws the data from the Streamsources.
     * 
     * @param [in] primType The mode the primitives should be drawn.
     * @param [in] size The number of Vertices that should be used.
     * @return GLMM_OK when ok.
     */
    GLMMRESULT DrawPrimitives (GLMMPRIMTYPE primType, unsigned first, unsigned size);

    /**
     * Draws the data from the Streamsources using the indices.
     * 
     * @param [in] primType The mode the primitives should be drawn.
     * @param [in] size The number of Indices that should be used.
     * @return GLMM_OK when ok.
     */
    GLMMRESULT DrawIndexedPrimitives (GLMMPRIMTYPE primType, unsigned first, unsigned size);
};


#endif /* ! __GLMM_DEVICE_H__ */ 

